/**
 * NodeReader - reads the node data and creates the corresponding data structures to represent these nodes
 * NodeTimeline - contains the list of nodes and their attributes
 * NodeTimeline - node dependencies - nodes and their relationships with each other
 * NodeTimeline - the temporal representation of the nodes
 */
class NodeTimelineReader
{
    NodeTimeline nodeTimeline

    // the source of the data
    RowDataReader nodeTimelineRDR

    NodeTimelineReader(RowDataReader nodeTimelineRDR)
    {
        this.nodeTimelineRDR = nodeTimelineRDR
    }

    void read()
    {
        // read the node timeline
        println "Reading Node Timeline:"
        def rowCallbackClosure = { row -> 
            println row.lastLineNumber() + "."+ row.getValueByLabel("Node")+"->" + row.getValueByLabel("Start Date")+ "," + row.getValueByLabel("End Date") + "," + row.getValueByLabel("Is Duration") 
        }

        nodeTimelineRDR.iterate(rowCallbackClosure)
    }

    static void main(args)
    {
        RowDataSource dataSource = new RowDataSource("./inputdata/node_timeline.csv", "CSV")
        CSVDataReader nodeTimelineRDR = new CSVDataReader(dataSource)

        NodeTimelineReader nodeTimelineReader = new NodeTimelineReader(nodeTimelineRDR)

        nodeTimelineReader.read()
    }
}
